﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="register.aspx.cs" Inherits="ncp.Web.register" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Src="uc/search.ascx" TagName="search"  TagPrefix="uc" %>
<%@ Register Src="uc/headTop.ascx" TagName="headTop"  TagPrefix="uc" %>
<%@ Register Src="uc/headLogo.ascx" TagName="headlogo"  TagPrefix="uc" %>
<%@ Register Src="/uc/menu.ascx" TagName="menu"  TagPrefix="uc" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>中国农业信息化服务商</title>
    <link href="css/module.css" rel="stylesheet" type="text/css" />
    <link href="css/page.css" rel="stylesheet" type="text/css" />
    <link href="css/reset.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="js/common.js" type="text/javascript"></script>

    <script src="Plugin/asyncbox/asyncbox.v1.5.beta.min.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <!--Head Begin-->
	<!--Head Top-->
<uc:headTop id="headtop" runat="server" />
	<!--Head Logo-->
<uc:headlogo id="headlogo" runat="server" />
	<!--Head Nav-->
<div id="head-nav">
	<div id="head-nav-center">
    	<uc:menu ID="menu" runat="server"/>
        <uc:search id="search" runat="server" />
    </div>
</div>
<!--Head End-->
<div class="bh-space"></div>

	<!--content begin-->
	<div class="bh-p-content">
    	<div class="bh-content">
			 <div class="bh-section">

					<div class="bh-register">
						<div class="bh-title">
							<h3>注册新用户</h3>
						</div>

						<div class="bh-con">
							<div class="bh-fl">
								<h4>填写您的信息：</h4>
								<p class="bh-field">
									<label>用户名：</label>
									<input type="text" class="bh-input-long required email" id="tbaccount"/>
									<span class="msg"></span>

								</p>
								<p class="bh-field">
									<label>设置密码：</label>
									<input type="password" class="required bh-input-long" id="tbpwd"/>
									<span class="msg"></span>
								</p>
								<p class="bh-field">
									<label>确认密码：</label>
									<input type="password" class="required bh-input-long" id="tbrepwd"/>
									<span class="msg"></span>
								</p>
								<p class="bh-field">
									<label>验证码：</label>
									<input type="text" class="required bh-input-small" id="tbcode"/>
									<img id="checkImage" src="/work/VerificationCode.aspx" width="93" height="25"  alt="验证码"　title="验证码" />
									<span >看不清 <span class="bh-blue bh-udline" style="cursor:pointer;" onclick="onfresh()" id="check" >换一张</span></span>
								</p>

								<p class="bh-reg-fwtk"><input type="checkbox" id="pro" style="vertical-align:text-bottom;"/><label for="pro" style="line-height: 20px;">&nbsp;请阅读<a href="javascript:void();" onclick="return onShowPro();" class="bh-red">《网站服务协议》</a></label> </p>
								<div class="bh-btn">
								    <input type="button" class="bh-lr-btn" value="注 册" onclick="onRegister()" id="btnreg"/>
								</div>
							</div>
							<div class="bh-fr">
								<p>我已经注册，现在就  <input name="" type="button" class="btn-login1" value="登录" onclick="window.location.href='/login.html'"/></p>

							</div>
						</div>
					</div>

			 </div>

        </div>
    </div>
	<!--content end-->
	<!--Foot Begin-->
<!--#include file="/uc/footer.htm"-->
<!--Foot End-->
	<!-- foot end -->
    </form>
</body>
</html>

<script type="text/javascript">
    $(function() {
        $("#tbaccount,#tbpwd,#tbrepwd,#tbcode,#pro").keypress(function(e) {
            var key = window.event ? e.keyCode : e.which;
            if (key.toString() == "13") {
                onRegister();
                return false;
            }
        });
    });
    function onRegister() {
        var account = $("#tbaccount").val();
        var pwd = $("#tbpwd").val();
        var repwd = $("#tbrepwd").val();
        var code = $("#tbcode").val();
        $("span.msg").text("");

        if (isEmpty("tbaccount")) {
            $("#tbaccount").next("span.msg").text("用户名不能为空！");
            $("#tbaccount").focus();
            return;
        }
        if (isEmpty("tbpwd")) {
            $("#tbpwd").next("span.msg").text("密码不能为空！");
            $("#tbpwd").focus();
            return;
        }
        if (pwd != repwd) {
            $("#tbrepwd").next("span.msg").text("两次输入密码不一致！");
            $("#tbrepwd").focus();
            return;
        }
        if ($.trim(code)=="") {
            alert("验证码不能为空");
            $("#tbcode").focus();
            return;
        }
        if (!$("#pro").attr("checked")) {
            alert("请先阅读并同意《网站服务协议》");
            $("#pro").focus();
            return;
        }
        //验证验证码
        var response = ncp.Web.register.VerificationCode(code);
        if (response.value != null) {
            var jsonOBJ = eval(response.value)[0];
            if (!jsonOBJ.isreload) {
                alert("验证码错误");
                $("#tbcode").focus();
                onfresh();
                return;
            }
            //注册
            var rep = ncp.Web.register.UerRegister(account, pwd);
            if (rep.value != null) {
                var json = eval(rep.value)[0];
                if (json.isreload) {
                    alert("用户注册成功，请完善个人资料！");
                    window.location.href = json.msg;
                } else {
                    alert(json.msg);
                }
            }
        }
    }
	//刷新验证码
	function onfresh() {
		var rand = Math.random()*1000;
		$("#checkImage").attr("src", "/work/VerificationCode.aspx?" + rand);
}
//服务条款
function onShowPro() {
    asyncbox.open({
        title: "网站服务协议",
        id: "prodia",
        url: "/html/pro.html",
        width: 600,
        height: 400,
        buttons: asyncbox.btn.YESNO,
        callback: function(buttonResult, contentWindow, returnValue) {
            if (buttonResult == 'yes') {
                $("#pro").attr("checked", true);
            } else {
            $("#pro").removeAttr("checked");
            }
        }
    });
    return false;
	}
</script>